package maze.net;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

public class SGMPOutputStream {

	private ObjectOutputStream out;

	public SGMPOutputStream(OutputStream stream) throws IOException {
		out = new ObjectOutputStream(stream);
	}

	public void send(MessageType message) throws IOException {
		//System.out.println("send: " + message);
		out.writeObject(message);
		out.flush();
	}
	
	public void send(MessageType message, byte bit8) throws IOException {
		//System.out.println("send: " + message);
		out.writeObject(message);
		out.writeByte(bit8);
		out.flush();
	}
	
	public void send(MessageType message, short bit16) throws IOException {
		System.out.println("send: " + message);
		out.writeObject(message);
		out.writeShort(bit16);
		out.flush();
	}
	
	public void send(MessageType message, int bit32) throws IOException {
		//System.out.println("send: " + message);
		out.writeObject(message);
		out.writeInt(bit32);
		out.flush();
	}
	
	public void send(MessageType message, long bit64) throws IOException {
		//System.out.println("send: " + message);
		out.writeObject(message);
		out.writeLong(bit64);
		out.flush();
	}
}